package org.ko.core.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.ko.core.logic.LogInfoService;
import org.ko.core.websupport.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 系统日志
 * @author zengxm 2014-9-26
 */
@Controller
@RequestMapping("sys/log")
public class LogInfoController extends BaseController{

	@Autowired
	private LogInfoService service;
	
	@Override
	protected String getTemplatePath() {
		return "core/system/log/";
	}

	/**
	 * <pre>
	 *
	 *</pre>
	 * @param req
	 * @param model
	 * @param page
	 * @param category
	 * @param keyword
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	@RequiresPermissions("log:list")
	@RequestMapping(value="list")
	//@Log(message="查看系统日志",category=Log.LOG, level=LogLevel.DEBUG)
	public String list(HttpServletRequest req, ModelMap model, Page page,
			String category, String keyword, Long userId) throws Exception {
		if(category==null)
			category = "";
		model.addAttribute("category", category);
		model.addAttribute("keyword", keyword);
		model.addAttribute("userId", userId);
		model.addAttribute(PAGINATION, service.findLog(page, category, keyword, (userId==null?0:userId.longValue())));
		return view(LIST);
	}
}